import { Link } from '@brillout/docpress'

Usage:
- `$ vike dev` Start development server.
- `$ vike build` Build for production.
- `$ vike preview` Start preview server using production build.
- `$ vike prerender` <Link href="/pre-rendering">Pre-render</Link> pages (only needed when <Link href="/prerender#disableautorun">`prerender.disableAutoRun`</Link> is `true`).
- `$ vike -v` Print Vike's version.

> **Can I use Vite's CLI instead?**
>
> Yes, you can — Vike has full-fledged support for third-party CLIs (Vite, Vitest, Storybook, ...).
>
> That said, we generally recommend using Vike's CLI for better DX. For example, you can pass Vike-specific settings like `$ vike build --prerender false` which isn't supported by third-party CLIs.

## Vike settings

#### CLI options

You can pass <Link href="/settings">any Vike setting</Link> to the CLI, for example:

```bash
# Make development server available over LAN and public addresses
$ vike dev --host

# Change port
$ vike preview --port 80

# Change mode
$ vike build --mode staging

# Change pre-render settings
$ vike build --prerender "{parallel:4,noExtraDir:true}"

# Disable Vite's cache
$ vike dev --force
```

> These are all Vike settings: <Link href="/host" noBreadcrumb />/<Link href="/port" noBreadcrumb />/<Link href="/mode" noBreadcrumb />/<Link href="/prerender" noBreadcrumb />/<Link href="/force" noBreadcrumb /> — note that Vike aliases some Vite settings for convenience, see <Link href="#vite-settings"/>.

> You can set values using JavaScript(-like) syntax (see <Link href="#json5-syntax" />).

#### `VIKE_CONFIG`

You can also use the `VIKE_CONFIG` environment variable, for example:

```bash
# Make development server available over LAN and public addresses
$ VIKE_CONFIG="{host:true}" vike dev

# Also when running Vike's CLI over a package.json script
$ VIKE_CONFIG="{prerender:{parallel:4,noExtraDir:true}}" npm run build
```

> You can set `VIKE_CONFIG` using JavaScript(-like) syntax (see <Link href="#json5-syntax" />).


## Vite settings

#### CLI options

Vike's CLI supports following [Vite CLI options](https://vite.dev/guide/cli#options):
 - `--host`
 - `--mode`
 - `--port`
 - `--force`

> These are Vike settings that alias Vite settings (see <Link href="/host" noBreadcrumb />/<Link href="/mode" noBreadcrumb />/<Link href="/port" noBreadcrumb />/<Link href="/force" noBreadcrumb />). Each Vike CLI option corresponds to a <Link href="/settings">Vike setting</Link>.
>
> Reach out if you believe some other Vite settings should also be aliased.

For other Vite settings, use `vite.config.js` or `VITE_CONFIG`.

#### `VITE_CONFIG`

You can use the `VITE_CONFIG` environment variable to pass [Vite settings](https://vite.dev/config/), for example:

```bash
# Set Vite's server.host setting to true
$ VITE_CONFIG="{server:{host:true}}" vike dev

# Also when running Vike's CLI over a package.json script
$ VITE_CONFIG="{build:{outDir:'build'}}" npm run build

# Also when running Vike's CLI over a package.json script
$ VITE_CONFIG="{mode:'staging'}" npm run preview
```

> You can set `VITE_CONFIG` using JavaScript(-like) syntax (see <Link href="#json5-syntax" />).



## JSON5 syntax

Vike uses [JSON5](https://json5.org) to parse the values of Vike's CLI options and the values of the environment variables `VITE_CONFIG` and `VIKE_CONFIG`.

It's a [JSON](https://json.org) extension that supports:
- Standard [JSON syntax](https://json.org/example.html)
- JavaScript-like syntax
  > For example `{someProp:'someVal'}` is valid JSON5 (it isn't valid `JSON`).
- Extra [JSON5 features](https://json5.org/#example)
  > For example comments — the following is valid JSON5 (it isn't valid `JSON`):
  > ```json5
  > // Some comment
  > {
  >    "someProp": "someVal"
  > }
  > ```



## See also

- <Link href="/api" />
